//package com.tsystems.school.jabber.server.workers;
//
//import java.nio.channels.SocketChannel;
//
//import com.tsystems.school.jabber.Message;
//import com.tsystems.school.jabber.MessageAttrs;
//import com.tsystems.school.jabber.MessageType;
//import com.tsystems.school.jabber.DataBase.DAO.*;
//import com.tsystems.school.jabber.DataBase.Entities.User;
//import com.tsystems.school.jabber.server.ConnectedUser;
//import com.tsystems.school.jabber.server.ConnectedUsers;
//import com.tsystems.school.jabber.server.IOWorker;
//
//
//public class LOGINWorker implements Worker{
//  private Message msg;
//  private SocketChannel sch;
//  private IOWorker iow;
//
//  public LOGINWorker(Message msg, SocketChannel sch, IOWorker iow){
//    this.msg = msg;
//    this.sch = sch;
//    this.iow = iow;
//  }
//
////  @Override
////  public void run() {
////    // TODO Auto-generated method stub
////    work(msg);
////  }
//
////  @Override
////  public Message work(Message msg) {
////    String slogin =  msg.getPropertyValue(MessageAttrs.LOGIN.getAttrname());
////
////
////    UserDAO userDAO = DAOFactory.getUserDAO();
////    User user = userDAO.getByLogin(slogin);
////    if (user == null){
////      return Message.getCancelMessage("User not exists");
////    } else {
////      String spass =  msg.getPropertyValue(MessageAttrs.PASS.getAttrname());
////      if (spass.equals(user.getPassword())){
////        ConnectedUser connUser = new ConnectedUser(user.getLogin(), sch.socket().getInetAddress().getHostAddress(), sch.socket().getPort(), sch, iow);
////        iow.setConnUser(connUser);
////        connUser.getWriteMessagePool().put(Message.getOkMessage());
////
////        //connUser.getWriteMessagePool().put(Message.getOkMessage());
////
////        //connUser.getWriteMessagePool().put(Message.getOkMessage());
////
////        ConnectedUsers.putUser(connUser);
////        return Message.getOkMessage();
////      }else
////        return Message.getCancelMessage("Wrong password");
////
////    }
//
//    //System.out.println(msg.getType().toString());
//    // TODO Auto-generated method stub
//
//  }
//
//
//}
